﻿using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.FileProviders;
using System.IO;

namespace MingYuanyun.WebApi.Abstractions
{
    public static class ApplicationBuilderExtensions
    {
        public static IApplicationBuilder UseHealthCheck(this IApplicationBuilder app, HealthCheckOptions options = null)
        {
            options = options ?? new HealthCheckOptions();

            app.UseStaticFiles(new StaticFileOptions
            {
                FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), options.Directory)),
                RequestPath = new PathString(options.RequestPath)
            });

            return app;
        }
    }
}
